package com.yang.contorller;

import com.yang.pojo.SysUser;
import com.yang.service.SysUserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * Created by 杨天可 on 2022/3/29 10:57
 */
@RestController
@RequestMapping("/api/register")
public class RegisterController {

    @Resource
    SysUserService sysUserService;

    /* 注册*/
    @PostMapping("/regist")
    public Map<String,Object> regist(@RequestBody SysUser sysUser){
        return sysUserService.regist(sysUser);
    }

    /* 校验验证码*/
    @GetMapping("/check")
    public Map<String,Object> check(@RequestParam("phone")String phone, @RequestParam("code")Integer code){
        return sysUserService.checkCode(phone, code);
    }

    /* 找回密码*/
    @PostMapping("/changePassword")
    public Map<String,Object> changePassword(@RequestBody Map<String,Object> map){
        String phone = (String)map.get("phone");
        String password = (String)map.get("password");
        return sysUserService.ChangePassword(phone, password);
    }
}
